#   库的引用
import PyQt6.QtWidgets as QtWidgets
import PyQt6.QtGui as QtGui
import PyQt6.QtCore as QtCore

#   增添任务
class AddTask(QtWidgets.QFrame):
    def __init__(self):
        super().__init__()
        self.setStyleSheet("QFrame{background: white; border-radius: 6px; margin-left: 3px; margin-top: 6px; margin-right: 6px; margin-bottom: 6px}")
        self.initUI()

    def initUI(self):
        self.vbox = QtWidgets.QVBoxLayout()
        self.vbox.setContentsMargins(6, 0, 6, 6)
        self.vbox.setSpacing(0)
        self.setLayout(self.vbox)

        #   任务名称
        self.labTitle = QtWidgets.QLabel("任务名称")
        self.labTitle.setStyleSheet("font-size: 16px")
        self.vbox.addWidget(self.labTitle)

        self.lineTitle = QtWidgets.QLineEdit()
        self.lineTitle.setStyleSheet("QLineEdit{border: 1px solid #BEBEBE; border-radius: 6px; font-size: 16px; padding-left: 5px}"
                                     "QLineEdit:hover{background-color: #cce4f7}"
                                     "QLineEdit:focus{background-color: #cce4f7; border: 1px solid #005499}")
        self.vbox.addWidget(self.lineTitle)

        #   任务描述
        self.labDescribe = QtWidgets.QLabel("任务描述")
        self.labDescribe.setStyleSheet("font-size: 16px")
        self.vbox.addWidget(self.labDescribe)

        self.textDescribe = QtWidgets.QLineEdit()
        self.textDescribe.setStyleSheet("QLineEdit{border: 1px solid #BEBEBE; border-radius: 6px; font-size: 16px; padding-left: 5px}"
                                        "QLineEdit:hover{background-color: #cce4f7}"
                                        "QLineEdit:focus{background-color: #cce4f7; border: 1px solid #005499}")
        self.vbox.addWidget(self.textDescribe)

        #   开始时间
        self.labDate = QtWidgets.QLabel("开始时间")
        self.labDate.setStyleSheet("font-size: 16px")
        self.vbox.addWidget(self.labDate)

        #   重复方式
        self.labRepeat = QtWidgets.QLabel("重复方式")
        self.labRepeat.setStyleSheet("font-size: 16px")
        self.vbox.addWidget(self.labRepeat)

        self.repeat_Widget = QtWidgets.QWidget()
        self.repeat_Layout = QtWidgets.QHBoxLayout()
        self.repeat_Layout.setContentsMargins(0, 0, 0, 0)
        self.repeat_Widget.setLayout(self.repeat_Layout)
        self.vbox.addWidget(self.repeat_Widget)
        self.vbox.addStretch(1)

        self.repeat_never = QtWidgets.QPushButton("从不重复")
        self.repeat_never.setCheckable(True)
        self.repeat_never.setChecked(True)
        self.repeat_never.setStyleSheet("font-size: 16px")
        self.repeat_Layout.addWidget(self.repeat_never)

        self.repeat_week = QtWidgets.QPushButton("每周一次")
        self.repeat_week.setStyleSheet("font-size: 16px")
        self.repeat_Layout.addWidget(self.repeat_week)

        self.repeat_day = QtWidgets.QPushButton("每日一次")
        self.repeat_day.setStyleSheet("font-size: 16px")
        self.repeat_Layout.addWidget(self.repeat_day)

        self.repeat_custom = QtWidgets.QPushButton("自定义")
        self.repeat_custom.setStyleSheet("font-size: 16px")
        self.repeat_Layout.addWidget(self.repeat_custom)
        self.repeat_Layout.addStretch(1)

        #   创建按钮与状态提示
        self.labStatus = QtWidgets.QLabel("")
        self.labStatus.setAlignment(QtCore.Qt.AlignmentFlag.AlignCenter)
        self.vbox.addWidget(self.labStatus)

        self.btnOK = QtWidgets.QPushButton("创建任务")
        self.btnOK.setStyleSheet("font-size: 16px")
        self.vbox.addWidget(self.btnOK)

    #   传递信息
    def report(self):
        info = dict()
        info["title"] = self.lineTitle.text()
        info["describe"] = self.textDescribe.text()
        return info
    
    #   初始化
    def initialize(self):
        self.lineTitle.setText("")
        self.textDescribe.setText("")
        self.labStatus.setText("")